In Study 4, college undergraduates completed a survey consisting of nine measures, including two indices of porosity, the Absorption scale, two indices of spiritual experience, two indices of more secular extraordinary experience, and two control measures.

This notebook contains exploratory factor analyses of item-wise data from this study.

source("../scripts_general/dependencies.R")
There were 26 warnings (use warnings() to see them)
source("../scripts_general/custom_funs.R")
source("../scripts_general/var_recode_contrast.R")
source("../scripts_general/data_load.R")
require(readxl)
d4_key <- read_excel("./data_by_question/Packet 7_CODED_March 18, 2019.xlsx", 
                     sheet = "Key") %>%
  rename(question = VARIABLE,
         question_text = QUESTION, 
         response_options = RESPONSES,
         coding = CODING) %>%
  mutate(question_text = gsub("[[:space:]]+", " ", question_text),
         question_text = gsub("’", "'", question_text),
         question_text = gsub("“", "'", question_text),
         question_text = gsub("”", "'", question_text),
         question_text = gsub("—", " - ", question_text),
         question_text = gsub("\\[ESP", "\\(ESP", question_text),
         question_text = gsub("psychic ability\\]", "psychic ability\\)", 
                              question_text),
         question_text = gsub(" \\[.*\\]", "", question_text),
         question_text = gsub("^[[:space:]]+", "", question_text))
nfact_fun <- function(df, which_rotate = "none") {
  
  res_par <- fa.parallel(df, plot = F)
  
  res_VSS <- VSS(df, n = 20, rotate = which_rotate, plot = F)
  
  res <- bind_rows(c(protocol = "Parallel analysis", 
                     nfact = res_par$nfact),
                   c(protocol = "Minimizing BIC", 
                     nfact = which.min(res_VSS$vss.stats$BIC)),
                   c(protocol = "Velicer's MAP",
                     nfact = which.min(res_VSS$map))) %>%
    mutate(nfact = as.numeric(nfact)) %>%
    arrange(nfact)
  
  return(res)
}

loadings_fun <- function(efa, key = d4_key) {
  res <- efa$loadings[] %>%
    data.frame() %>%
    rownames_to_column("question") %>%
    mutate(order = 1:nrow(.)) %>%
    gather(factor, loading, -c(question, order)) %>%
    left_join(key %>% select(question, question_text)) %>%
    mutate(scale = gsub("p7_", "", question),
           scale = gsub("_.*$", "", scale),
           scale_abbrev = factor(scale,
                                 levels = c("se", "dse", "por", "mm", "abs",
                                            "unev", "exsen", "hthk", "wob"),
                                 labels = c("SE", "DSE", "PS", "PV", "Abs.",
                                            "Hall.", "Para.", "NC", "SCM")),
           scale = factor(scale,
                          levels = c("se", "dse", "por", "mm", "abs",
                                     "unev", "exsen", "hthk", "wob"),
                          labels = c("Spiritual Events", 
                                     "Daily Spiritual Experiences",
                                     "Porosity Scale", "Porosity Vignettes",
                                     "Absorption", "Hallucinations", "Paranormal",
                                     "Need for Cognition", 
                                     "Sense of Control: Mastery")))
  
  return(res)
}

heatmap_fun <- function(df, wrap_width = 100, facet = F, legend = F, abbrev = T) {
  
  if (abbrev) {
    df <- df %>%
      mutate(scale = scale_abbrev,
             question_text = gsub("^.\\. ", "", question_text),
             question_text = gsub("^..\\. ", "", question_text),
             question_text = gsub("^.\\) ", "", question_text),
             question_text = gsub("^..\\) ", "", question_text))
  }

  if (!facet) {
    df <- df %>%
      unite(question_text, scale, question_text, sep = ": ")
  }
  
  plot <- ggplot(df,
                 aes(x = factor, 
                     y = reorder(str_wrap(question_text, wrap_width), desc(order)), 
                     fill = loading)) +
    geom_tile(color = "black", size = 0.1) +
    geom_text(aes(label = format(round(loading, 2), nsmall = 2)), size = 2) +
    scale_fill_viridis_c(guide = guide_colorbar(barwidth = 6, barheight = 0.5)) +
    scale_x_discrete(position = "top") +
    scale_y_discrete(position = "right") +
    theme_minimal() +
    theme(legend.position = "top") +
    labs(x = "Factor", y = "Question")
  
  if (facet) {
    plot <- plot + 
      facet_grid(rows = vars(scale), space = "free", scales = "free", switch = "y")
  }
  
  if (!legend) {
    plot <- plot + theme(legend.position = "none")
  }
  
  return(plot)
} 

topfact_fun <- function(df) {
  res <- df %>%
    group_by(question) %>%
    top_n(1, abs(loading)) %>%
    ungroup() %>%
    distinct(question, factor) %>%
    rename(topfact = factor)
  
  return(res)
}

All items, standardized by site

d4_items_all_std <- read_csv("./data_by_question/study4_byquestion.csv") %>%
  select(-X1, -ends_with("_cat"), -contains("_dem_"), 
         -contains("_total"), -contains("_check"),
         -ends_with("_physical"), # omit "physically" items from porosity vignettes
         -ends_with("_a"), -ends_with("_b"), -ends_with("_c")) %>%
  filter(p7_subj %in% d4$subject_id) %>%
  group_by(p7_ctry) %>%
  mutate_at(vars(-p7_ctry, -p7_subj), ~ scale(.)) %>%
  ungroup() %>%
  unite(ctry_subj, p7_ctry, p7_subj) %>%
  column_to_rownames("ctry_subj")
Missing column names filled in: 'X1' [1]Parsed with column specification:
cols(
  .default = col_double(),
  p7_ctry = col_character(),
  p7_abs_check = col_character(),
  p7_dse_check = col_character(),
  p7_se_check = col_character(),
  p7_unev_check = col_character(),
  p7_exsen_check = col_character(),
  p7_por_check = col_character(),
  p7_mm_check = col_character(),
  p7_dem_sex = col_character(),
  p7_dem_pocc = col_character(),
  p7_dem_major = col_character(),
  p7_dem_ethnicity = col_character(),
  p7_dem_rur.urb = col_character(),
  p7_dem_affrd.basics = col_character(),
  p7_dem_religion = col_character(),
  p7_dem_church = col_character(),
  p7_dem_holy.tung.gif = col_character(),
  p7_abs_child.exp_cat = col_logical(),
  p7_abs_poetic_cat = col_logical(),
  p7_abs_tv.real_cat = col_logical()
  # ... with 162 more columns
)
See spec(...) for full column specifications.

Factor retention

nfact_all_std <- nfact_fun(d4_items_all_std)
Parallel analysis suggests that the number of factors =  15  and the number of components =  12 
nfact_all_std

5-factor solution

efa_all_std_5 <- fa(d4_items_all_std, nfactors = 5, rotate = "varimax") %>% fa.sort()
colnames(efa_all_std_5$loadings) <- paste0("F", str_pad(1:5, width = 2, pad = "0"))
colnames(efa_all_std_5$Vaccounted) <- paste0("F", str_pad(1:5, width = 2, pad = "0"))
efa_all_std_5_loadings <- loadings_fun(efa_all_std_5)
Joining, by = "question"
efa_all_std_5$Vaccounted
                             F01        F02        F03        F04        F05
SS loadings           9.11307208 7.63959345 7.00343041 6.43602871 3.41634965
Proportion Var        0.06372778 0.05342373 0.04897504 0.04500719 0.02389056
Cumulative Var        0.06372778 0.11715151 0.16612655 0.21113374 0.23502430
Proportion Explained  0.27115400 0.22731152 0.20838287 0.19150017 0.10165144
Cumulative Proportion 0.27115400 0.49846552 0.70684839 0.89834856 1.00000000
heatmap_fun(efa_all_std_5_loadings)

efa_all_std_5_topfact <- topfact_fun(efa_all_std_5_loadings)
efa_all_std_5_topfact %>%
  left_join(efa_all_std_5_loadings %>% distinct(question, scale)) %>%
  count(topfact, scale) %>%
  spread(topfact, n)
Joining, by = "question"
efa_all_std_5_topfact %>% count(topfact)

Table S62. Factor loadings from of an exploratory factor analysis of item-wise data from all measures included in Study 4

Note that the version of this table included in the Supplement was lightly edited in Microsoft Word.

efa_all_std_5_loadings %>%
  select(scale, question_text, factor, loading, order) %>%
  mutate(factor = gsub("F0", "Factor ", factor),
         loading = format(round(loading, 2), nsmall = 2)) %>%
  spread(factor, loading) %>%
  arrange(order) %>%
  select(-order) %>%
  # mutate("Factor 1" = cell_spec(`Factor 1`, "html",
  #                               bold = c(rep(T, 35), 
  #                                        rep(F, nrow(.) - 35))),
  #        "Factor 2" = cell_spec(`Factor 2`, "html",
  #                               bold = c(rep(F, 35), 
  #                                        rep(T, 17), 
  #                                        rep(F, nrow(.) - (35 + 17)))),
  #        "Factor 3" = cell_spec(`Factor 3`, "html",
  #                               bold = c(rep(F, 35 + 17), 
  #                                        rep(T, 21),
  #                                        rep(F, nrow(.) - (35 + 17 + 21)))),
  #        "Factor 4" = cell_spec(`Factor 4`, "html",
  #                               bold = c(rep(F, 35 + 17 + 21), 
  #                                        rep(T, 45),
  #                                        rep(F, nrow(.) - (35 + 17 + 21 + 45)))),
  #        "Factor 5" = cell_spec(`Factor 5`, "html",
  #                               bold = c(rep(F, 35 + 17 + 21 + 45), 
  #                                        rep(T, 25)))) %>%
  kable(format = "html", escape = F) %>%
  kable_styling()

scale question_text Factor 1 Factor 2 Factor 3 Factor 4 Factor 5
Porosity Vignettes c. Could Martha being envious make it so that a spirit could hurt Joanne? 0.64 -0.02 0.18 0.01 -0.04
Porosity Vignettes c. Could Mary being angry make it so that a spirit could hurt Jane? 0.63 0.02 0.20 -0.03 -0.05
Porosity Vignettes 4. Some people think that people have thoughts or feelings that can harm others directly, even if they don't tell others about these thoughts and feelings. Do you think that is possible? 0.61 0.02 0.19 0.09 0.01
Porosity Vignettes 5. Can spirits use people's thoughts and feelings to hurt other people? 0.60 0.17 0.19 0.07 0.01
Porosity Vignettes c. Could Sarah being caring make it so that a spirit could help Barbara? 0.58 0.05 0.20 0.08 0.02
Porosity Scale 12. Spirits hear spoken curses and carry out their instructions. 0.58 0.21 0.10 0.07 -0.01
Porosity Vignettes e. Suppose Joanne fell ill after Martha was envious of her. Could Martha's envy be the cause? 0.57 -0.05 0.19 0.03 -0.07
Porosity Vignettes b. Could Martha hurt Joanne just by thinking envious thoughts about her? 0.57 -0.09 0.19 0.02 -0.07
Porosity Scale 14. Spirits can put thoughts in our minds. 0.54 0.35 0.05 0.08 0.02
Porosity Scale 17. Some people can visualize a symbol and the visualization can change the world directly. 0.54 -0.07 0.10 0.15 0.11
Porosity Scale 15. Some people use special powers to put thoughts in other people's minds and make them do something like fall in love. 0.54 0.17 0.06 0.06 0.01
Porosity Scale 6. Spirits can read our thoughts and act on them even if we don't speak about them out loud. 0.53 0.23 0.02 0.06 -0.04
Porosity Scale 13. There are some people who can curse other people and make them sick or otherwise affect their mind or body. 0.52 0.27 0.00 0.11 -0.05
Porosity Vignettes e. Suppose Jane got sick after Mary got angry with her. Do you think Mary's anger could be the cause? 0.52 0.02 0.22 0.07 -0.10
Porosity Scale 4. When people get angry, sometimes evil spirits take advantage and control the actions of the angry person. 0.51 0.24 0.02 0.04 -0.01
Porosity Scale 1. Spirits can use thoughts and feelings to hurt people. 0.50 0.16 -0.02 0.09 -0.05
Porosity Scale 8. There are some people who can truly consult with (or otherwise connect to) the unseen and answer questions for people. 0.49 0.15 0.02 0.07 0.03
Porosity Vignettes a. If Martha wanted to hurt Joanne with her envious feelings, could she do that? 0.48 0.01 0.08 0.05 -0.08
Porosity Scale 7. There are certain people (witches/wizards) who can hurt people or contaminate food with their stare. 0.47 0.16 0.04 0.07 -0.02
Porosity Scale 3. If someone wishes in their mind that their friend finds a job (even without speaking the wish or praying to God), the spiritual effects of that wish can help their friend find a new job. 0.45 0.14 0.13 0.07 -0.01
Porosity Vignettes e. Suppose Barbara felt better after Sarah had caring feelings for her. Could Sarah's caring feelings be the cause? 0.44 0.07 0.10 0.05 0.02
Porosity Scale 5. Envious thoughts and feelings come from evil spirits. 0.43 0.25 -0.02 0.05 -0.05
Porosity Scale 16. If someone is sick and you can't call or visit them, thinking good thoughts can still help them get better. 0.43 0.02 0.03 0.06 0.04
Porosity Vignettes b. Could Barbara help Sarah just by thinking caring thoughts about her, without praying? 0.43 -0.04 0.12 0.16 0.00
Porosity Vignettes b. Could Mary hurt Jane just by thinking angry thoughts about her? 0.42 -0.05 0.16 0.04 -0.09
Porosity Scale 2. Evil thoughts can go out into the world like Wi-Fi or a radio - like radio waves going directly into the world - and cause bad things to happen to other people without a spirit's help. 0.41 0.25 -0.03 0.09 -0.02
Paranormal 7). I am completely convinced that it is possible to send a "mental message" to another person, or in some way influence them at a distance, by means other than normal means of communication. 0.36 0.11 0.13 0.25 -0.03
Porosity Scale 9. A simple prayer to God in your mind can cause you to win the lottery, or cure a person from AIDS. 0.34 0.23 0.11 0.05 0.05
Porosity Vignettes a. If Mary wanted to hurt Jane with her angry feelings, could she do that? 0.34 0.03 0.06 0.15 0.00
Porosity Scale 10. If you pray hard enough in your mind to God, you can bring back the dead. 0.33 0.10 0.14 -0.01 0.05
Paranormal 8). I am completely convinced that I have had at least one experience of sending a "mental message" between myself and another person. 0.33 0.04 0.04 0.22 -0.01
Paranormal 2). I am completely convinced that I have had a personal experience of ESP. (ESP is extrasensory perception, or psychic ability) 0.31 0.11 0.15 0.22 -0.02
Paranormal 1). I am completely convinced that ESP exists. (ESP is extrasensory perception, or psychic ability) 0.29 0.16 0.04 0.17 -0.02
Paranormal 3). I am completely convinced that I am psychic. 0.23 -0.03 0.19 0.12 0.02
Porosity Vignettes a. If Sarah wanted to help Barbara with her caring feelings, without praying to God, could she do that? 0.21 0.00 0.05 0.14 -0.01
Daily Spiritual Experiences 9. I feel guided by God in the midst of daily activities. 0.14 0.73 0.17 0.05 -0.02
Daily Spiritual Experiences 10. I feel God's love for me, directly. 0.15 0.73 0.10 0.05 0.02
Daily Spiritual Experiences 8. I ask for God's help in the midst of daily activities. 0.07 0.72 0.06 0.00 -0.10
Daily Spiritual Experiences 5. I find comfort in my religion or spirituality. 0.13 0.69 0.13 0.00 -0.02
Daily Spiritual Experiences 4. I find strength in my religion or spirituality. 0.18 0.69 0.11 -0.02 0.08
Daily Spiritual Experiences 3. During worship, or at other times when connecting with God, I feel joy which lifts me out of my daily concerns. 0.13 0.67 0.21 0.03 -0.04
Daily Spiritual Experiences 1. I feel God's presence. 0.15 0.65 0.19 -0.03 0.01
Daily Spiritual Experiences 11. I feel God's love for me, through others. 0.17 0.61 0.15 0.01 0.10
Daily Spiritual Experiences 12. I am spiritually touched by the beauty of creation. 0.15 0.55 0.08 0.21 0.04
Spiritual Events 3. Have you felt that God or a spirit placed thoughts inside your head? 0.15 0.54 0.42 0.07 0.08
Daily Spiritual Experiences 13. I feel thankful for my blessings. 0.13 0.53 -0.01 0.08 0.09
Daily Spiritual Experiences 6. I feel deep inner peace or harmony. 0.11 0.46 0.10 0.07 0.15
Spiritual Events 15. Have you ever had a feeling of overwhelming emotion during prayer? 0.14 0.37 0.34 0.13 -0.01
Daily Spiritual Experiences 2. I experience a connection to all of life. 0.18 0.35 0.17 0.15 0.09
Daily Spiritual Experiences 15. I accept others even when they do things I think are wrong. 0.12 0.27 0.06 0.13 0.24
Daily Spiritual Experiences 14. I feel a selfless caring for others. 0.08 0.27 0.05 0.24 0.26
Need for Cognition 7. I only think as hard as I have to. -0.03 -0.13 0.01 -0.10 0.00
Spiritual Events 8. Have you ever felt that you tasted God or a spirit? 0.23 0.02 0.65 -0.01 0.04
Spiritual Events 18. Have you ever felt that a supernatural force, like the Holy Spirit or a demon, took control of your body, so that you were not making the choice of whether to move but still you moved? 0.15 -0.01 0.59 0.05 -0.06
Spiritual Events 6. Have you ever felt that God or a spirit touch you, maybe on the shoulder or on the hand, in a way you felt on your body? 0.14 0.14 0.56 0.11 0.05
Spiritual Events 14. Have you ever had an experience of uncontrollable shaking or trembling during prayer, or been slain in the spirit? 0.19 0.12 0.56 0.05 -0.05
Spiritual Events 17. Have you ever had an out-of-body experience, in which you were separated from your body and you could see your body from the outside? 0.17 -0.10 0.55 0.08 0.00
Spiritual Events 7. Have you ever felt that you smelled God or a spirit? That is, have you ever smelled something that is not of this material world? 0.18 0.05 0.55 0.02 -0.06
Spiritual Events 1. Have you ever heard God or a spirit speak to you in a voice you felt you heard outside your head? 0.08 0.25 0.55 0.11 0.07
Spiritual Events 10. Have you ever felt God or a spirit near-tangibly present, as if standing there by your side? 0.09 0.37 0.53 0.10 -0.03
Spiritual Events 5. Have you ever felt that God or a spirit placed an image inside your head? 0.09 0.30 0.53 0.14 -0.03
Spiritual Events 21. Have you ever experienced the presence of God through illness (including as warning or punishment)? 0.17 0.20 0.53 0.01 -0.01
Spiritual Events 22. Have you ever experienced the presence of God in a miraculous healing (that you saw in person, not on television)? 0.14 0.32 0.51 0.08 0.00
Spiritual Events 4. Have you ever had a vision, that is, seen something not quite in your mind, that you felt was given to you by God or a spirit? 0.08 0.37 0.47 0.08 -0.04
Spiritual Events 2. Have you heard God or a spirit speak to you in a voice that you felt you experienced inside your head? 0.08 0.46 0.47 0.07 0.04
Spiritual Events 20. Have you ever experienced the presence of God through pain (such as headaches, bodily aches and pains, stomachaches)? 0.16 0.08 0.47 0.04 -0.07
Spiritual Events 12. Have you ever felt a demonic presence as if it was there in the room with you? 0.20 0.14 0.46 0.17 -0.09
Spiritual Events 16. Have you ever had a sense of intense power shoot through you during prayer? 0.14 0.33 0.45 0.08 0.05
Spiritual Events 23. Have you ever experienced the presence of God through your own miraculous healing? 0.12 0.33 0.45 0.12 0.05
Spiritual Events 13. Have you ever experienced a supernatural presence that was not God, a spirit, or a demon? 0.20 0.07 0.43 0.28 -0.11
Spiritual Events 9. Have you ever had a dream you felt was sent by God or a spirit? 0.15 0.39 0.43 0.12 0.00
Spiritual Events 19. Have you ever had the experience of being awake but unable to move? 0.07 -0.01 0.37 0.22 0.02
Hallucinations 7. I see shadows and shapes when there is nothing there. 0.17 -0.04 0.30 0.26 -0.07
Absorption 35) I can be deeply moved by a sunset. 0.02 0.01 0.00 0.48 -0.02
Absorption 17) It is sometimes possible for me to be completely immersed in nature or art and to feel as if my whole state of consciousness has somehow been temporarily altered. 0.10 0.02 -0.05 0.44 0.00
Absorption 31) The sound of a voice can be so fascinating to me that I can just go on listening to it. 0.07 0.11 -0.04 0.44 -0.05
Absorption 32) At times I somehow feel the presence of someone who is not physically there. 0.06 0.07 0.11 0.42 0.04
Absorption 33) Sometimes thoughts and images come to me without the slightest effort on my part. 0.01 0.10 0.03 0.40 -0.06
Absorption 28) Some music reminds me of pictures or changing color patterns. 0.04 0.00 0.07 0.40 0.07
Absorption 15) I can often somehow sense the presence of another person before I actually see or hear her/him. 0.06 0.08 0.02 0.39 0.03
Absorption 24) I often take delight in small things (like the five-pointed star shape that appears when you cut an apple across the core or the colors in soap bubbles). -0.01 -0.01 -0.01 0.38 0.05
Absorption 30) I often have 'physical memories': for example, after I have been swimming I may still feel as if I am in the water. 0.09 -0.03 0.09 0.38 -0.02
Absorption 21) Things that might seem meaningless to others often make sense to me. -0.04 0.12 -0.06 0.37 0.07
Absorption 34) I find that different odors have different colors. 0.16 -0.07 0.07 0.37 -0.07
Hallucinations 6. I have had the experience of hearing a person's voice and then found that there was no one there. 0.10 0.09 0.32 0.36 -0.12
Absorption 7) If I wish, I can imagine (or daydream) some things so vividly that they hold my attention as a good movie or story does. 0.06 0.03 -0.05 0.36 0.06
Absorption 27) Some of my most vivid memories are called up by scents and smells. 0.04 0.07 0.10 0.36 -0.08
Absorption 12) Sometimes I experience things as if they were 'doubly' real. 0.03 0.09 0.10 0.35 0.01
Absorption 20) I can sometimes recollect certain past experiences in my life with such clarity and vividness that it is like living them again or almost so. 0.11 0.09 0.00 0.35 0.04
Absorption 6) I like to watch cloud shapes change in the sky. 0.06 -0.08 0.00 0.33 0.02
Absorption 19) I am able to wander off into my thoughts while doing a routine task and then find a few minutes later that I have completed it. 0.09 0.08 -0.05 0.33 0.05
Absorption 18) Different colors have distinctive and special meanings for me. 0.09 0.07 0.00 0.33 0.09
Absorption 16) The crackle and flames of a wood fire stimulate my imagination. 0.12 -0.05 0.20 0.32 0.05
Absorption 23) My thoughts often don't occur as words but as visual images. 0.09 0.02 0.03 0.32 0.04
Hallucinations 1. I hear a voice speaking my thoughts aloud. 0.17 0.09 0.22 0.32 0.02
Absorption 4) If I stare at a picture and then look away from it, I can sometimes 'see' an image of the picture almost as if I were still looking at it. 0.00 0.07 0.03 0.32 -0.01
Absorption 14) If I wish I can imagine that my body is so heavy that I could not move it if I wanted to. 0.09 -0.03 0.10 0.32 0.05
Hallucinations 4. I can hear music when it is not being played. 0.07 -0.04 0.19 0.32 -0.08
Absorption 25) When listening to organ music or other powerful music I sometimes feel as if I am being lifted into the air. 0.05 0.06 0.13 0.31 0.02
Absorption 22) While acting in a play I think I could really feel the emotions of the character and 'become' her/him for the time being, forgetting both myself and the audience. 0.11 0.11 0.08 0.30 -0.01
Absorption 5) Sometimes I feel as if my mind could envelop the whole world. 0.11 0.02 0.17 0.30 0.12
Absorption 26) Sometimes I can change noise into music by the way I listen to it. 0.05 -0.03 0.09 0.30 0.06
Need for Cognition 18. I usually end up deliberating about issues even when they do not affect me personally. 0.02 0.02 0.04 0.30 0.17
Hallucinations 3. I hear people call my name and find that nobody has done so. 0.08 0.04 0.23 0.30 -0.07
Absorption 3) While watching a movie, a TV show, or a play, I may become so involved that I may forget about myself and my surroundings and experience the story as if it were real and as if I were taking part in it. 0.08 0.06 0.01 0.28 -0.01
Absorption 9) I sometimes 'step outside' my usual self and experience an entirely different state of being. 0.04 -0.04 0.15 0.28 0.05
Absorption 13) When I listen to music I can get so caught up in it that I don't notice anything else. 0.04 -0.03 -0.08 0.26 0.02
Absorption 29) I often know what someone is going to say before he or she says it. 0.05 0.06 0.12 0.26 0.10
Absorption 10) Textures - such as wool, sand, wood - sometimes remind me of colors or music. 0.12 0.00 0.12 0.26 0.02
Absorption 1) Sometimes I feel and experience things as I did as a child. 0.00 -0.05 0.04 0.25 -0.03
Hallucinations 2. I hear the telephone ring and find that I am mistaken. 0.13 -0.04 0.22 0.25 -0.09
Paranormal 5). I am completely convinced that I have had at least one dream that came true and which (I believe) was not just a coincidence. 0.19 0.20 0.02 0.25 -0.01
Sense of Control: Mastery 9. There are many things that interfere with what I want to do. 0.07 -0.11 -0.05 -0.23 0.20
Absorption 8) I think I really know what some people mean when they talk about mystical experiences. 0.11 0.08 0.11 0.23 0.11
Paranormal 4). I am completely convinced that I have had at least one premonition about the future that came true and which (I believe) was not just a coincidence. 0.17 0.15 0.09 0.21 -0.06
Need for Cognition 12. Learning new ways to think doesn't excite me very much. -0.08 0.04 -0.08 0.19 0.18
Absorption 2) I can be greatly moved by eloquent or poetic language. -0.04 0.09 0.05 0.19 -0.04
Need for Cognition 16. I feel relief rather than satisfaction after completing a task that requires a lot of mental effort. -0.03 -0.05 -0.03 -0.15 0.02
Need for Cognition 2. I like to have the responsibility of handling a situation that requires a lot of thinking. -0.05 0.07 0.09 0.21 0.46
Sense of Control: Mastery 7. Other people determine most of what I can and cannot do. 0.06 -0.01 -0.05 -0.17 0.46
Sense of Control: Mastery 11. There is really no way I can solve the problems I have. 0.01 0.04 -0.06 -0.06 0.42
Sense of Control: Mastery 8. What happens in my life is often beyond my control. 0.01 -0.06 -0.08 -0.20 0.41
Sense of Control: Mastery 1. I can do just about anything I really set my mind to. -0.02 0.19 -0.02 0.02 0.39
Sense of Control: Mastery 6. I often feel helpless in dealing with the problems of life. 0.06 -0.04 -0.01 -0.20 0.39
Need for Cognition 11. I really enjoy a task that involves coming up with new solutions to problems. -0.06 0.05 0.00 0.26 0.37
Sense of Control: Mastery 2. When I really want to do something, I usually find a way to succeed at it. -0.04 0.13 -0.05 0.04 0.37
Need for Cognition 13. I prefer my life to be filled with puzzles I must solve. 0.04 -0.02 0.11 0.24 0.36
Need for Cognition 15. I would prefer a task that is intellectual, difficult, and important to one that is somewhat important but does not require much thought. -0.05 0.00 0.02 0.25 0.35
Sense of Control: Mastery 12. I sometimes feel I am being pushed around in my life. 0.02 0.00 -0.05 -0.21 0.35
Sense of Control: Mastery 10. I have little control over the things that happen to me. 0.07 -0.03 -0.07 -0.18 0.34
Need for Cognition 14. The notion of thinking abstractly is appealing to me. 0.03 0.07 0.10 0.29 0.34
Need for Cognition 3. Thinking is not my idea of fun. -0.06 -0.05 -0.02 0.11 0.34
Sense of Control: Mastery 3. Whether or not I am able to get what I want is in my own hands. -0.02 0.04 0.03 0.08 0.32
Sense of Control: Mastery 5. There is little I can do to change many of the important things in my life. 0.01 -0.09 0.07 -0.14 0.30
Need for Cognition 6. I find satisfaction in deliberating hard and for long hours. 0.01 0.04 0.05 0.26 0.30
Need for Cognition 10. The idea of relying on thought to make my way to the top appeals to me. 0.00 0.01 0.05 0.29 0.29
Need for Cognition 4. I would rather do something that requires little thought than something that is sure to challenge my thinking abilities. -0.12 0.03 0.03 0.08 0.29
Need for Cognition 1. I prefer complex to simple problems. -0.04 0.09 0.13 0.13 0.28
Sense of Control: Mastery 4. What happens to me in the future mostly depends on me. -0.05 0.02 -0.05 0.13 0.28
Need for Cognition 5. I try to anticipate and avoid situations where there is a likely chance I will have to think in depth about something. -0.14 -0.05 -0.08 0.01 0.23
Need for Cognition 8. I prefer to think about small daily projects to long term ones. -0.01 -0.01 -0.10 -0.08 0.23
Need for Cognition 17. It's enough for me that something gets the job done; I don't care how or why it works. 0.07 0.07 -0.03 0.06 0.20
Need for Cognition 9. I like tasks that require little thought once I've learned them. -0.06 -0.04 0.00 -0.03 0.18

NA

15-factor solution

efa_all_std_15 <- fa(d4_items_all_std, nfactors = 15, rotate = "varimax") %>% fa.sort()
colnames(efa_all_std_15$loadings) <- paste0("F", str_pad(1:15, width = 2, pad = "0"))
colnames(efa_all_std_15$Vaccounted) <- paste0("F", str_pad(1:15, width = 2, pad = "0"))
efa_all_std_15_loadings <- loadings_fun(efa_all_std_15)
Joining, by = "question"
efa_all_std_15$Vaccounted
                             F01        F02        F03       F04        F05        F06        F07
SS loadings           7.03975050 6.82848187 5.65619497 5.3718236 5.35176866 3.21743776 2.69431161
Proportion Var        0.04922902 0.04775162 0.03955381 0.0375652 0.03742496 0.02249956 0.01884134
Cumulative Var        0.04922902 0.09698065 0.13653446 0.1740997 0.21152461 0.23402418 0.25286552
Proportion Explained  0.14014587 0.13593998 0.11260234 0.1069411 0.10654188 0.06405207 0.05363779
Cumulative Proportion 0.14014587 0.27608585 0.38868818 0.4956293 0.60217120 0.66622327 0.71986106
                             F08        F09        F10        F11        F12        F13
SS loadings           2.25043678 2.18092994 2.15322979 2.07686313 1.52961846 1.43319168
Proportion Var        0.01573732 0.01525126 0.01505755 0.01452352 0.01069663 0.01002232
Cumulative Var        0.26860284 0.28385410 0.29891165 0.31343517 0.32413180 0.33415412
Proportion Explained  0.04480122 0.04341749 0.04286604 0.04134575 0.03045132 0.02853168
Cumulative Proportion 0.76466228 0.80807977 0.85094581 0.89229157 0.92274289 0.95127457
                              F14         F15
SS loadings           1.271339563 1.176216682
Proportion Var        0.008890486 0.008225291
Cumulative Var        0.343044604 0.351269895
Proportion Explained  0.025309560 0.023415874
Cumulative Proportion 0.976584126 1.000000000
heatmap_fun(efa_all_std_15_loadings %>%
              mutate(question_text = ifelse(nchar(question_text) <= 80,
                                            question_text,
                                            paste0(substr(question_text, 1, 80), 
                                                   "..."))), 
            wrap_width = 80)

efa_all_std_15_topfact <- topfact_fun(efa_all_std_15_loadings)
efa_all_std_15_topfact %>%
  left_join(efa_all_std_15_loadings %>% distinct(question, scale)) %>%
  count(topfact, scale) %>%
  spread(topfact, n) %>%
  janitor::adorn_totals(where = "col")
Joining, by = "question"
                       scale F01 F02 F03 F04 F05 F06 F07 F08 F09 F10 F11 F12 F13 F14 Total
            Spiritual Events   1  20  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA   1  NA    22
 Daily Spiritual Experiences  13  NA  NA  NA  NA   1  NA  NA  NA  NA  NA  NA  NA  NA    14
              Porosity Scale  NA  NA   2  NA  13  NA  NA  NA  NA  NA  NA  NA  NA   1    16
          Porosity Vignettes  NA  NA  14  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA    14
                  Absorption  NA  NA  NA  32  NA   1  NA  NA  NA  NA  NA   1  NA  NA    34
              Hallucinations  NA  NA  NA   1  NA  NA  NA   5  NA  NA  NA  NA  NA  NA     6
                  Paranormal  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA   7  NA  NA  NA     7
          Need for Cognition  NA  NA  NA  NA  NA   9  NA  NA  NA   9  NA  NA  NA  NA    18
   Sense of Control: Mastery  NA  NA  NA  NA  NA  NA   8  NA   4  NA  NA  NA  NA  NA    12

All items, standardized collapsing across sites

d4_items_all <- read_csv("./data_by_question/study4_byquestion.csv") %>%
  select(-X1, -ends_with("_cat"), -contains("_dem_"), 
         -contains("_total"), -contains("_check"),
         -ends_with("_physical"), # omit "physically" items from porosity vignettes
         -ends_with("_a"), -ends_with("_b"), -ends_with("_c")) %>%
  filter(p7_subj %in% d4$subject_id) %>%
  unite(ctry_subj, p7_ctry, p7_subj) %>%
  column_to_rownames("ctry_subj") %>%
  mutate_all(~ scale(.))
Missing column names filled in: 'X1' [1]Parsed with column specification:
cols(
  .default = col_double(),
  p7_ctry = col_character(),
  p7_abs_check = col_character(),
  p7_dse_check = col_character(),
  p7_se_check = col_character(),
  p7_unev_check = col_character(),
  p7_exsen_check = col_character(),
  p7_por_check = col_character(),
  p7_mm_check = col_character(),
  p7_dem_sex = col_character(),
  p7_dem_pocc = col_character(),
  p7_dem_major = col_character(),
  p7_dem_ethnicity = col_character(),
  p7_dem_rur.urb = col_character(),
  p7_dem_affrd.basics = col_character(),
  p7_dem_religion = col_character(),
  p7_dem_church = col_character(),
  p7_dem_holy.tung.gif = col_character(),
  p7_abs_child.exp_cat = col_logical(),
  p7_abs_poetic_cat = col_logical(),
  p7_abs_tv.real_cat = col_logical()
  # ... with 162 more columns
)
See spec(...) for full column specifications.

Factor retention

nfact_all <- nfact_fun(d4_items_all)
Parallel analysis suggests that the number of factors =  12  and the number of components =  11 
nfact_all

6-factor solution

efa_all_6 <- fa(d4_items_all, nfactors = 6, rotate = "oblimin") %>% fa.sort()
colnames(efa_all_6$loadings) <- paste0("F", str_pad(1:6, width = 2, pad = "0"))
efa_all_6_loadings <- loadings_fun(efa_all_6)
Joining, by = "question"
heatmap_fun(efa_all_6_loadings)

efa_all_6_topfact <- topfact_fun(efa_all_6_loadings)
efa_all_6_topfact %>%
  left_join(efa_all_6_loadings %>% distinct(question, scale)) %>%
  count(topfact, scale) %>%
  spread(topfact, n)
Joining, by = "question"

12-factor solution

efa_all_12 <- fa(d4_items_all, nfactors = 12, rotate = "oblimin") %>% fa.sort()
colnames(efa_all_12$loadings) <- paste0("F", str_pad(1:12, width = 2, pad = "0"))
efa_all_12_loadings <- loadings_fun(efa_all_12)
Joining, by = "question"
heatmap_fun(efa_all_12_loadings %>%
              mutate(question_text = ifelse(nchar(question_text) <= 100,
                                            question_text,
                                            paste0(substr(question_text, 1, 100), 
                                                   "..."))), 
            wrap_width = 60)

efa_all_12_topfact <- topfact_fun(efa_all_12_loadings)
efa_all_12_topfact %>%
  left_join(efa_all_12_loadings %>% distinct(question, scale)) %>%
  count(topfact, scale) %>%
  spread(topfact, n)
Joining, by = "question"

15-factor solution

efa_all_15 <- fa(d4_items_all, nfactors = 15, rotate = "oblimin") %>% fa.sort()
convergence not obtained in GPFoblq. 1000 iterations used.
colnames(efa_all_15$loadings) <- paste0("F", str_pad(1:15, width = 2, pad = "0"))
efa_all_15_loadings <- loadings_fun(efa_all_15)
Joining, by = "question"
heatmap_fun(efa_all_15_loadings %>%
              mutate(question_text = ifelse(nchar(question_text) <= 80,
                                            question_text,
                                            paste0(substr(question_text, 1, 80), 
                                                   "..."))), 
            wrap_width = 80)

efa_all_15_topfact <- topfact_fun(efa_all_15_loadings)
efa_all_15_topfact %>%
  left_join(efa_all_15_loadings %>% distinct(question, scale)) %>%
  count(topfact, scale) %>%
  spread(topfact, n)
Joining, by = "question"
LS0tCnRpdGxlOiAiU3R1ZHkgNDogRXhwbG9yYXRvcnkgZmFjdG9yIGFuYWx5c2VzIgpzdWJ0aXRsZTogIkx1aHJtYW5uLCBXZWlzbWFuLCBldCBhbC4iCm91dHB1dDogCiAgaHRtbF9ub3RlYm9vazoKICAgIHRvYzogdHJ1ZQogICAgdG9jX2Zsb2F0OiB0cnVlCiAgICBjb2RlX2ZvbGRpbmc6IGhpZGUKLS0tCgpJbiBTdHVkeSA0LCBjb2xsZWdlIHVuZGVyZ3JhZHVhdGVzIGNvbXBsZXRlZCBhIHN1cnZleSBjb25zaXN0aW5nIG9mIG5pbmUgbWVhc3VyZXMsIGluY2x1ZGluZyB0d28gaW5kaWNlcyBvZiBwb3Jvc2l0eSwgdGhlIEFic29ycHRpb24gc2NhbGUsIHR3byBpbmRpY2VzIG9mIHNwaXJpdHVhbCBleHBlcmllbmNlLCB0d28gaW5kaWNlcyBvZiBtb3JlIHNlY3VsYXIgZXh0cmFvcmRpbmFyeSBleHBlcmllbmNlLCBhbmQgdHdvIGNvbnRyb2wgbWVhc3VyZXMuCgpUaGlzIG5vdGVib29rIGNvbnRhaW5zIGV4cGxvcmF0b3J5IGZhY3RvciBhbmFseXNlcyBvZiBpdGVtLXdpc2UgZGF0YSBmcm9tIHRoaXMgc3R1ZHkuCgpgYGB7ciwgbWVzc2FnZSA9IEZ9CnNvdXJjZSgiLi4vc2NyaXB0c19nZW5lcmFsL2RlcGVuZGVuY2llcy5SIikKc291cmNlKCIuLi9zY3JpcHRzX2dlbmVyYWwvY3VzdG9tX2Z1bnMuUiIpCnNvdXJjZSgiLi4vc2NyaXB0c19nZW5lcmFsL3Zhcl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T4lCiAgICBkYXRhLmZyYW1lKCkgJT4lCiAgICByb3duYW1lc190b19jb2x1bW4oInF1ZXN0aW9uIikgJT4lCiAgICBtdXRhdGUob3JkZXIgPSAxOm5yb3coLikpICU+JQogICAgZ2F0aGVyKGZhY3RvciwgbG9hZGluZywgLWMocXVlc3Rpb24sIG9yZGVyKSkgJT4lCiAgICBsZWZ0X2pvaW4oa2V5ICU+JSBzZWxlY3QocXVlc3Rpb24sIHF1ZXN0aW9uX3RleHQpKSAlPiUKICAgIG11dGF0ZShzY2FsZSA9IGdzdWIoInA3XyIsICIiLCBxdWVzdGlvbiksCiAgICAgICAgICAgc2NhbGUgPSBnc3ViKCJfLiokIiwgIiIsIHNjYWxlKSwKICAgICAgICAgICBzY2FsZV9hYmJyZXYgPSBmYWN0b3Ioc2NhbGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldmVscyA9IGMoInNlIiwgImRzZSIsICJwb3IiLCAibW0iLCAiYWJzIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAidW5ldiIsICJleHNlbiIsICJodGhrIiwgIndvYiIpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYWJlbHMgPSBjKCJTRSIsICJEU0UiLCAiUFMiLCAiUFYiLCAiQWJzLiIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIkhhbGwuIiwgIlBhcmEuIiwgIk5DIiwgIlNDTSIpKSwKICAgICAgICAgICBzY2FsZSA9IGZhY3RvcihzY2FsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICBsZXZlbHMgPSBjKCJzZSIsICJkc2UiLCAicG9yIiwgIm1tIiwgImFicyIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAidW5ldiIsICJleHNlbiIsICJodGhrIiwgIndvYiIpLAogICAgICAgICAgICAgICAgICAgICAgICAgIGxhYmVscyA9IGMoIlNwaXJpdHVhbCBFdmVudHMiLCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJEYWlseSBTcGlyaXR1YWwgRXhwZXJpZW5jZXMiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIlBvcm9zaXR5IFNjYWxlIiwgIlBvcm9zaXR5IFZpZ25ldHRlcyIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiQWJzb3JwdGlvbiIsICJIYWxsdWNpbmF0aW9ucyIsICJQYXJhbm9ybWFsIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJOZWVkIGZvciBDb2duaXRpb24iLCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJTZW5zZSBvZiBDb250cm9sOiBNYXN0ZXJ5IikpKQogIAogIHJldHVybihyZXMpCn0KCmhlYXRtYXBfZnVuIDwtIGZ1bmN0aW9uKGRmLCB3cmFwX3dpZHRoID0gMTAwLCBmYWNldCA9IEYsIGxlZ2VuZCA9IEYsIGFiYnJldiA9IFQpIHsKICAKICBpZiAoYWJicmV2KSB7CiAgICBkZiA8LSBkZiAlPiUKICAgICAgbXV0YXRlKHNjYWxlID0gc2NhbGVfYWJicmV2LAogICAgICAgICAgICAgcXVlc3Rpb25fdGV4dCA9IGdzdWIoIl4uXFwuICIsICIiLCBxdWVzdGlvbl90ZXh0KSwKICAgICAgICAgICAgIHF1ZXN0aW9uX3RleHQgPSBnc3ViKCJeLi5cXC4gIiwgIiIsIHF1ZXN0aW9uX3RleHQpLAogICAgICAgICAgICAgcXVlc3Rpb25fdGV4dCA9IGdzdWIoIl4uXFwpICIsICIiLCBxdWVzdGlvbl90ZXh0KSwKICAgICAgICAgICAgIHF1ZXN0aW9uX3RleHQgPSBnc3ViKCJeLi5cXCkgIiwgIiIsIHF1ZXN0aW9uX3RleHQpKQogIH0KCiAgaWYgKCFmYWNldCkgewogICAgZGYgPC0gZGYgJT4lCiAgICAgIHVuaXRlKHF1ZXN0aW9uX3R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gICAgIGJvbGQgPSBjKHJlcChGLCAzNSksIAogICMgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVwKFQsIDE3KSwgCiAgIyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXAoRiwgbnJvdyguKSAtICgzNSArIDE3KSkpKSwKICAjICAgICAgICAiRmFjdG9yIDMiID0gY2VsbF9zcGVjKGBGYWN0b3IgM2AsICJodG1sIiwKICAjICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvbGQgPSBjKHJlcChGLCAzNSArIDE3KSwgCiAgIyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXAoVCwgMjEpLAogICMgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVwKEYsIG5yb3coLikgLSAoMzUgKyAxNyArIDIxKSkpKSwKICAjICAgICAgICAiRmFjdG9yIDQiID0gY2VsbF9zcGVjKGBGYWN0b3IgNGAsICJodG1sIiwKICAjICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvbGQgPSBjKHJlcChGLCAzNSArIDE3ICsgMjEpLCAKICAjICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcChULCA0NSksCiAgIyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXAoRiwgbnJvdyguKSAtICgzNSArIDE3ICsgMjEgKyA0NSkpKSksCiAgIyAgICAgICAgIkZhY3RvciA1IiA9IGNlbGxfc3BlYyhgRmFjdG9yIDVgLCAiaHRtbCIsCiAgIyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib2xkID0gYyhyZXAoRiwgMzUgKyAxNyArIDIxICsgNDUpLCAKICAjICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcChULCAyNSkpKSkgJT4lCiAga2FibGUoZm9ybWF0ID0gImh0bWwiLCBlc2NhcGUgPSBGKSAlPiUKICBrYWJsZV9zdH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